package cn.it.shop.listener;

import java.util.Timer;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import cn.it.shop.start.InterfaceUrlInti;
import cn.it.shop.util.QuartzJob;

/**
 * 定时器任务设置监听器
 *
 */
@WebListener
public class InitTimerTask implements ServletContextListener {

	
	
	/***
	 * 执行定时器业务逻辑
	 */
	@Override
	public void contextInitialized(ServletContextEvent event) {
		System.out.println("进入监听器");
		//读取属性配置文件初始化参数,保存进全局变量,为获取access_token做好准备
		InterfaceUrlInti.init();
		
		QuartzJob quartzJob = new QuartzJob();
		new Timer(true).schedule(quartzJob, 0, 2000*60*60);//2小时获取一次
		//new Timer(true).schedule(quartzJob, 0, 100*60);//10秒中取一次,结果20秒刷新一次
	}
	
	/**
	 * 销毁时
	 */
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		
	}
	
}
